import Vue from "vue";
import VueRouter from "vue-router";
import Layout from '@/layout'


Vue.use(VueRouter);
//供货单
export const orderRoute = [
    {
        path: '/home',
        component: Layout,
        redirect: '/home/index',
        meta: { title: '供货单签订流程', icon: 'el-icon-menu' },
        children: [
            {
                path: 'index',
                component: () => import('@/views/home/index'),
                name: 'Home',
                meta: { title: '获取待办签报号', active: 'index' }
            },
            {
                path: 'getMaterial',
                component: () => import('@/views/getMaterial/getMaterial'),
                name: 'getMaterial',
                meta: { title: '获取物资采购合同', active: 'getMaterial' }
            },

            {
                path: 'infoCompare',
                component: () => import('@/views/infoCompare/infoCompare'),
                name: 'InfoCompare',
                meta: { title: '订单信息检查', active: 'infoCompare' }
            },
            {
                path: 'syManifests',
                component: () => import('@/views/syManifests/syManifests'),
                name: 'syManifests',
                meta: { title: '同步订单到ECP', active: 'syManifests' }
            },
            {
                path: 'purchaseOrder',
                component: () => import('@/views/purchaseOrder/purchaseOrder'),
                name: 'PurchaseOrder',
                meta: { title: 'ECP订单分配', active: 'purchaseOrder' }
            },
            {
                path: 'supplyOrder',
                component: () => import('@/views/supplyOrder/supplyOrder'),
                name: 'SupplyOrder',
                meta: { title: 'ECP订单获取', active: 'supplyOrder' }
            },
            {
                path: 'ecpOrder',
                component: () => import('@/views/ecpOrder/ecpOrder'),
                name: 'EcpOrder',
                meta: { title: 'ECP订单检查', active: 'ecpOrder' }
            },
            {
                path: 'ecpCreate',
                component: () => import('@/views/ecpCreate/ecpCreate'),
                name: 'EcpCreate',
                meta: { title: 'ECP订单生成', active: 'ecpCreate' }
            },
            {
                path: 'savePdf',
                component: () => import('@/views/savePdf/savePdf'),
                name: 'SavePdf',
                meta: { title: '签章文件下载', active: 'savePdf' }
            },
            {
                path: 'pdfSearch',
                component: () => import('@/views/pdfSearch/pdfSearch'),
                name: 'PdfSearch',
                meta: { title: '签章文件检查', active: 'pdfSearch' }
            },
            {
                path: 'drftEffect',
                component: () => import('@/views/drftEffect/drftEffect'),
                name: 'DrftEffect',
                meta: { title: 'ECP合同生效', active: 'drftEffect' }
            },
            {
                path: 'contractExam',
                component: () => import('@/views/contractExam/contractExam'),
                name: 'ContractExam',
                meta: { title: '合同生效检查', active: 'contractExam' }
            },
            {
                path: 'deleteDate',
                component: () => import('@/views/deleteDate/deleteDate'),
                name: 'DeleteDate',
                meta: { title: '数据清除', active: 'deleteDate' }
            },
        ]
    },
]
//批次合同
export const constractRoute = [
    {
        path: '/constract',
        component: Layout,
        redirect: '/constract/winningBid',
        meta: { title: '前置数据准备', icon: 'el-icon-platform-eleme' },
        children: [
            {
                path: 'winningBid',
                // path2: '/constract/winningBid',
                component: () => import('@/views/constract/winningBid'),
                name: 'WinningBid',
                meta: { title: '获取中标结果公告', active: 'winningBid' }
            },
            {
                path: 'notAssigned',
                // path2: '/constract/notAssigned',
                component: () => import('@/views/constract/notAssigned'),
                name: 'NotAssigned',
                meta: { title: '获取未分配合同', active: 'notAssigned' }
            },
            // {
            //     path: 'range',
            //     path2: '/constract/range',
            //     component: () => import('@/views/constract/range'),
            //     name: 'Range',
            //     meta: { title: '确定招标批次范围', active: 'range' }
            // },
        ]
    },
    {
        path: '/draft',
        component: Layout,
        redirect: '/draft/noCount',
        meta: { title: '合同起草前检查', icon: 'el-icon-menu' },
        children: [
            {
                path: 'noCount',
                // path2: '/draft/noCount',
                component: () => import('@/views/Draft/noCount'),
                name: 'NoCount',
                meta: { title: '未分配数量检查', active: 'noCount' }
            },
            {
                path: 'exam',
                // path2: '/draft/exam',
                component: () => import('@/views/Draft/exam'),
                name: 'Exam',
                meta: { title: '执行合同分配', active: 'exam' }
            },
            {
                path: 'create',
                // path2: '/draft/create',
                component: () => import('@/views/Draft/create'),
                name: 'Create',
                meta: { title: '生成合同草稿', active: 'create' }
            },
            {
                path: 'get',
                // path2: '/draft/get',
                component: () => import('@/views/Draft/get'),
                name: 'Get',
                meta: { title: '获取已分配合同', active: 'get' }
            },
            {
                path: 'rightGet',
                // path2: '/draft/rightGet',
                component: () => import('@/views/Draft/rightGet'),
                name: 'RightGet',
                meta: { title: '产权属性获取', active: 'rightGet' }
            },
            {
                path: 'rights',
                // path2: '/draft/rights',
                component: () => import('@/views/Draft/rights'),
                name: 'Rights',
                meta: { title: '产权属性检查', active: 'rights' }
            },
            {
                path: 'constractInfo',
                // path2: '/draft/constractInfo',
                component: () => import('@/views/Draft/constractInfo'),
                name: 'ConstractInfo',
                meta: { title: '合同信息检查', active: 'constractInfo' }
            },
            {
                path: 'save',
                // path2: '/draft/save',
                component: () => import('@/views/Draft/save'),
                name: 'Save',
                meta: { title: '合同文件保存', active: 'save' }
            },
        ]
    },
    {
        path: '/executeCon',
        component: Layout,
        redirect: '/executeCon/executeDrft',
        meta: { title: '执行合同起草', icon: 'el-icon-s-help' },
        children: [
            {
                path: 'executeDrft',
                // path2: '/executeCon/executeDrft',
                component: () => import('@/views/executeCon/executeDrft'),

                name: 'ExecuteDrft',
                meta: { title: '执行合同起草', active: 'executeDrft' }
            },
            // {
            //     path: 'notice',
            //     path2: '/executeCon/notice',
            //     component: () => import('@/views/executeCon/notice'),
            //     name: 'Notice',
            //     meta: { title: '通知供应商确认', active: 'notice' }
            // },
            {
                path: 'approval',
                // path2: '/executeCon/approval',
                component: () => import('@/views/executeCon/approval'),
                name: 'Approval',
                meta: { title: '执行合同审批', active: 'approval' }
            },
            {
                path: 'transmitErp',
                // path2: '/executeCon/transmitErp',
                component: () => import('@/views/executeCon/transmitErp'),
                name: 'TransmitErp',
                meta: { title: 'ERP检查传输 ', active: 'transmitErp' }
            },
            {
                path: 'examErp',
                // path2: '/executeCon/examErp',
                component: () => import('@/views/executeCon/examErp'),
                name: 'ExamErp',
                meta: { title: '创建合同检查', active: 'examErp' }
            },
            {
                path: 'createErp',
                // path2: '/executeCon/createErp',
                component: () => import('@/views/executeCon/createErp'),
                name: 'CreateErp',
                meta: { title: 'ERP创建合同 ', active: 'createErp' }
            },

            {
                path: 'reviseErp',
                // path2: '/executeCon/reviseErp',
                component: () => import('@/views/executeCon/reviseErp'),
                name: 'ReviseErp',
                meta: { title: 'ERP修改承办人ID ', active: 'reviseErp' }
            },
            {
                path: 'createOrder',
                // path2: '/executeCon/createOrder',
                component: () => import('@/views/executeCon/createOrder'),
                name: 'CreateOrder',
                meta: { title: 'ERP创建订单 ', active: 'createOrder' }
            },
            {
                path: 'createOrderFailCheck',
                // path2: '/executeCon/createOrder',
                component: () => import('@/views/executeCon/createOrderFailCheck'),
                name: 'CreateOrderFailCheck',
                meta: { title: '创建订单失败检查 ', active: 'createOrderFailCheck' }
            },

            {
                path: 'createCheck',
                // path2: '/executeCon/createCheck',
                component: () => import('@/views/executeCon/createCheck'),
                name: 'CreateCheck',
                meta: { title: '创建订单后检查 ', active: 'createCheck' }
            },
        ]
    },
    {
        path: '/examAfter',
        component: Layout,
        redirect: '/examAfter/transEcp',
        meta: { title: '合同起草后检查', icon: 'el-icon-s-claim' },
        children: [
            {
                path: 'transCheck',
                // path2: '/examAfter/transEcp',
                component: () => import('@/views/examAfter/transCheck'),
                name: 'TransCheck',
                meta: { title: '经法号传输检查', active: 'transEcp' }
            },
            {
                path: 'transEcp',
                // path2: '/examAfter/transEcp',
                component: () => import('@/views/examAfter/transEcp'),
                name: 'TransEcp',
                meta: { title: '经法号传输ECP', active: 'transEcp' }
            },
            {
                path: 'startSign',
                // path2: '/examAfter/startSign',
                component: () => import('@/views/examAfter/startSign'),
                name: 'StartSign',
                meta: { title: '启动电子签章', active: 'startSign' }
            },
            {
                path: 'signDownload',
                // path2: '/examAfter/signDownload',
                component: () => import('@/views/examAfter/signDownload'),
                name: 'SignDownload',
                meta: { title: '签章文件下载 ', active: 'signDownload' }
            },
            {
                path: 'signature',
                // path2: '/examAfter/signature',
                component: () => import('@/views/examAfter/signature'),
                name: 'Signature',
                meta: { title: '签章文件检查', active: 'signature' }
            },
            {
                path: 'drftExam',
                // path2: '/examAfter/drftExam',
                component: () => import('@/views/examAfter/drftExam'),
                name: 'DrftExam',
                meta: { title: '执行合同生效', active: 'drftExam' }
            },
            {
                path: 'effectiveCheck',
                component: () => import('@/views/examAfter/effectiveCheck'),
                name: 'EffectiveCheck',
                meta: { title: '合同生效检查', active: 'effectiveCheck' }
            },
            {
                path: 'deleteDate',
                component: () => import('@/views/examAfter/deleteDate'),
                name: 'DeleteDate',
                meta: { title: '数据清除', active: 'deleteDate' }
            },

        ]
    }
]
//辅助决策
export const auxiliaryRoute = [
    {
        path: '/auxiliary',
        component: Layout,
        redirect: '/auxiliary/progress',
        meta: { title: '统计分析', icon: 'el-icon-s-help' },
        children: [
            {
                path: 'progress',
                // path2: '/auxiliary/progress',
                component: () => import('@/views/auxiliary/progress'),
                name: 'Progress',
                meta: { title: '业务进度统计', active: 'progress' }
            },
            {
                path: 'errorInfo',
                // path2: '/auxiliary/errorInfo',
                component: () => import('@/views/auxiliary/errorInfo'),
                name: 'ErrorInfo',
                meta: { title: '错误信息统计', active: 'errorInfo' }
            }

        ]
    }
]
//框架合同
export const frameRoute = [
    {
        path: '/frame',
        component: Layout,
        redirect: '/frame/announcement',
        meta: { title: '前置数据准备', icon: 'el-icon-platform-eleme' },
        children: [
            {
                path: 'announcement',
                component: () => import('@/views/frame/announcement'),
                name: 'Announcement',
                meta: { title: '获取中标结果公告', active: 'announcement' }
            },
            {
                path: 'assignedNot',
                component: () => import('@/views/frame/assignedNot'),
                name: 'AssignedNot',
                meta: { title: '获取未分配合同', active: 'assignedNot' }
            },
        ]
    },
    {
        path: '/draft',
        component: Layout,
        redirect: '/draft/assignedNotInfoCheck',
        meta: { title: '合同起草前检查', icon: 'el-icon-menu' },
        children: [
            {
                path: 'assignedNotInfoCheck',
                component: () => import('@/views/frame/assignedNotInfoCheck'),
                name: 'AssignedNotInfoCheck',
                meta: { title: '未分配数量检查', active: 'assignedNotInfoCheck' }
            },
            {
                path: 'assignedNotData',
                component: () => import('@/views/frame/assignedNotData'),
                name: 'AssignedNotData',
                meta: { title: '执行合同分配', active: 'assignedNotData' }
            },
            {
                path: 'contractDraftGenerate',
                component: () => import('@/views/frame/contractDraftGenerate'),
                name: 'ContractDraftGenerate',
                meta: { title: '生成合同草稿', active: 'contractDraftGenerate' }
            },
            {
                path: 'getAssigned',
                component: () => import('@/views/frame/getAssigned'),
                name: 'GetAssigned',
                meta: { title: '获取已分配合同', active: 'getAssigned' }
            },
            {
                path: 'ownerProperty',
                component: () => import('@/views/frame/ownerProperty'),
                name: 'OwnerProperty',
                meta: { title: '产权属性获取', active: 'ownerProperty' }
            },
            {
                path: 'attributeCheck',
                component: () => import('@/views/frame/attributeCheck'),
                name: 'AttributeCheck',
                meta: { title: '产权属性检查', active: 'attributeCheck' }
            },
            {
                path: 'ecpContractInfoCheck',
                component: () => import('@/views/frame/ecpContractInfoCheck'),
                name: 'EcpContractInfoCheck',
                meta: { title: '合同信息检查', active: 'ecpContractInfoCheck' }
            },
            {
                path: 'contractFileDownload',
                component: () => import('@/views/frame/contractFileDownload'),
                name: 'ContractFileDownload',
                meta: { title: '合同文件保存', active: 'contractFileDownload' }
            },

        ]
    },
    {
        path: '/executeCon',
        component: Layout,
        redirect: '/executeCon/contractDrafting',
        meta: { title: '执行合同起草', icon: 'el-icon-s-help' },
        children: [
            {
                path: 'contractDrafting',
                component: () => import('@/views/frame/contractDrafting'),

                name: 'ContractDrafting',
                meta: { title: '执行合同起草', active: 'contractDrafting' }
            },
            {
                path: 'contractApproval',
                component: () => import('@/views/frame/contractApproval'),
                name: 'ContractApproval',
                meta: { title: '执行合同审批', active: 'contractApproval' }
            },
            {
                path: 'checkTransmciss',
                component: () => import('@/views/frame/checkTransmiss'),
                name: 'CheckTransmiss',
                meta: { title: 'ERP检查传输', active: 'checkTransmiss' }
            },
            {
                path: 'guaranteeLetter',
                component: () => import('@/views/frame/guaranteeLetter'),
                name: 'GuaranteeLetter',
                meta: { title: 'ERP维护保函', active: 'guaranteeLetter' }
            },
            // {
            //     path: 'priceErp',
            //     component: () => import('@/views/frame/priceErp'),
            //     name: 'PriceErp',
            //     meta: { title: 'ERP价格联动', active: 'priceErp' }
            // },
            {
                path: 'generateCheck',
                component: () => import('@/views/frame/generateCheck'),
                name: 'GenerateCheck',
                meta: { title: '库存生成检查', active: 'generateCheck' }
            },
            {
                path: 'inventoryGenerate',
                component: () => import('@/views/frame/inventoryGenerate'),
                name: 'InventoryGenerate',
                meta: { title: '协议库存生成', active: 'inventoryGenerate' }
            },
            {
                path: 'generateFailCheck',
                component: () => import('@/views/frame/generateFailCheck'),
                name: 'GenerateFailCheck',
                meta: { title: '生成失败检查', active: 'generateFailCheck' }
            },
            {
                path: 'checkUploadEcp',
                component: () => import('@/views/frame/checkUploadEcp'),
                name: 'CheckUploadEcp',
                meta: { title: '经法号传输检查', active: 'checkUploadEcp' }
            },
            {
                path: 'erpUploadEcp',
                component: () => import('@/views/frame/erpUploadEcp'),
                name: 'ErpUploadEcp',
                meta: { title: '经法号传输ECP', active: 'erpUploadEcp' }
            },
            {
                path: 'fStartSignature',
                component: () => import('@/views/frame/fStartSignature'),
                name: 'FStartSignature',
                meta: { title: '启动电子签章', active: 'fStartSignature' }
            },
            {
                path: 'fSignFileDownload',
                component: () => import('@/views/frame/fSignFileDownload'),
                name: 'FSignFileDownload',
                meta: { title: '签章文件下载', active: 'fSignFileDownload' }
            },
            {
                path: 'fSignFileCheck',
                component: () => import('@/views/frame/fSignFileCheck'),
                name: 'FSignFileCheck',
                meta: { title: '签章文件检查', active: 'fSignFileCheck' }
            },
            {
                path: 'fContractEffect',
                component: () => import('@/views/frame/fContractEffect'),
                name: 'FContractEffect',
                meta: { title: 'ECP合同生效', active: 'fContractEffect' }
            },
        ]
    },
]

export const allRouter = [
    {
        path: '/',
        redirect: '/login',// 当访问根路径时重定向到登录页
        hidden: true
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login/login'),
        hidden: true
    },
    {
        path: '/module',
        name: 'ModuleSelect',
        hidden: true,
        component: () => import('@/views/moduleSelect/index'),
    },
    ...orderRoute,
    ...constractRoute,
    ...auxiliaryRoute,
    ...frameRoute
]

const router = new VueRouter({
    mode: 'hash', // 使用 hash 模式
    routes: allRouter
});
// router.beforeEach((to, from, next) => {
//     let isAuthenticated = true    //已经登录
//     if (to.path === '/login' && isAuthenticated) {
//         next('/module'); // 如果用户已登录并试图访问登录页，则重定向到主页
//     }
//     else if (to.path !== '/login' && !isAuthenticated) {
//         next('/login'); // 如果需要认证但用户未登录，则重定向到登录页
//     }
//     else {
//         next(); // 
//     }
// });


export default router;